package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.config.Result;
import com.atguigu.springcloud.entities.Payment;
import com.atguigu.springcloud.service.ProduceSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * @author : zhenyu
 * @Date : 2022/9/5 16:30
 **/

@Api(value = "生产者", tags = "生产者")
@RestController
@RequestMapping("/producer")
@Slf4j
public class ProducerController {

    @Autowired
    private ProduceSerivce produceSerivce;

    @PostMapping("/sendMessage")
    @ApiOperation("生产者发送消息到MQ")
    public Result<String> sendMessage(@RequestParam("exchage")String exchage,
                                      @RequestParam("routingKey")String routingKey,
                                      @RequestParam("message") String message)
            throws ParseException {
        produceSerivce.sendMessage(exchage, routingKey, message);
        return Result.success("发送成功");
    }

}
